package com.mobile.ado.util;

import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.provider.ContactsContract;

public class ContentProviderHelper {

	public static Cursor getAllSystemContactsWithoutAnySelection(Context context) {
		ContentResolver contentResolver = context.getContentResolver();
		Cursor cursor = contentResolver.query(
				ContactsContract.Contacts.CONTENT_URI, null, null, null,
				ContactsContract.Contacts.DISPLAY_NAME + " collate NOCASE ASC");
		return cursor;
	}

	public static Cursor getAllSystemContactsByName(Context context, String name) {
		ContentResolver contentResolver = context.getContentResolver();
		Cursor cursor = contentResolver.query(
				ContactsContract.Contacts.CONTENT_URI, null,
				ContactsContract.Contacts.DISPLAY_NAME + " LIKE ?",
				new String[] { "%" + name + "%" },
				ContactsContract.Contacts.DISPLAY_NAME + " collate NOCASE ASC");
		return cursor;
	}

	public static Cursor getAllPhoneNumbers(Context context, String id) {
		ContentResolver contentResolver = context.getContentResolver();
		Cursor cursor = contentResolver.query(
				ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,
				ContactsContract.CommonDataKinds.Phone.CONTACT_ID + "=?",
				new String[] { id }, null);
		return cursor;
	}

}
